/*
 * 패키지 이름 적절히 바꾸세요
 */
package emp;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.util.Iterator;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;

import emp.empDAO;
import emp.empVO;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.border.LineBorder;
import javax.swing.LayoutStyle.ComponentPlacement;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.tools.JavaCompiler;

import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class DogMain extends JFrame {

	private JPanel contentPane;
	private JTable dogTable;		// 유기견 테이블
	private JTable empTable;		// 직원 테이블
	private JTable adoTable;		// 입양자 테이블
	private JTextField Id;			// 로그인 화면에서 아이디 입력 필드
	private JPasswordField pwd;		// 로그인 화면에서 비밀번호 입력 필드
	private JButton loginBtn; 		// 로그인 화면에서 로그인 버튼
	private JButton regBtn; 		// 로그인 화면에서 회원 가입 버튼
	private JTextField searchBtn;	// 로그아웃 화면에서 검색 버튼
	private JButton logoutBtn;		// 로그아웃 화면에서 로그아웃 버튼
	private JLabel txtInfo;			// 로그아웃 화면에서 사용자 이름이나 정보가 표시되는 라벨
	private JTextField txtEmpno;
	private JTextField ename;
	private JTextField ssn1;
	private JTextField ssn2;
	private JTextField addr;
	private JTextField phone1;
	private JTextField phone2;
	private JTextField phone3;
	private JTextField sname;
	private JTextField dname;
	private JTextField job;
	private JTextField sal;
	private JTextField hiredate;
	private JTextField mgr;
	private JTextField month;
	private JTextField day;

	private empVO ev = new empVO();
	private empDAO ed = new empDAO();
	private JTextField txtFind;
	/*
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					DogMain frame = new DogMain();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	
	
	/*
	 * 기본 생성자
	 */
	public DogMain(){
		initialize();
	}
	
	/*
	 * Create the frame.
	 * 
	 * 기본 판넬 구조
	 * contentPane	- headpanel ; 윗 부분 개그림 레이블이 들어가는 판넬
	 * 				- memberPanel ; 로그인 폼이 들어가는 판넬
	 * 							- loginPanel ; 로그인 화면이 표시되는 판넬
	 * 							- logoutPanel ; 로그인 후의 화면이 표시되는 판넬
	 * 				- mainPanel	; 아랫 부분이 주요 내용들이 표시되는 판넬 cardLayout으로 구성
	 * 							- tabPanel ; 각 탭들이 들어가는 판넬
	 * 							- indexPanel ; 프로그램 최초 구동시 표시되는 판넬
	 * 							- myPanel ; 회원 정보 수정 및 삭제를 표시하는 판넬
	 * 							- adminpanel ; 관리자용 관리 페이지가 표시되는 판넬
	 */				
	private void initialize() {
		setTitle("유기견 관리 프로그램");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1024, 768);
		setLocationRelativeTo(null);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JPanel headPanel = new JPanel();
		headPanel.setMaximumSize(new Dimension(32767, 200));
		headPanel.setPreferredSize(new Dimension(10, 100));
		headPanel.setBackground(Color.LIGHT_GRAY);
		contentPane.add(headPanel, BorderLayout.NORTH);
		
		JPanel memberPanel = new JPanel();
		memberPanel.setMaximumSize(new Dimension(32767, 100));
		contentPane.add(memberPanel, BorderLayout.CENTER);
		memberPanel.setLayout(new CardLayout(0, 0));
		
		JPanel loginPanel = new JPanel();
		FlowLayout flowLayout = (FlowLayout) loginPanel.getLayout();
		flowLayout.setVgap(20);
		flowLayout.setHgap(20);
		flowLayout.setAlignment(FlowLayout.LEFT);
		memberPanel.add(loginPanel, "loginPanel");
		
		JLabel txtId = new JLabel("아이디");
		loginPanel.add(txtId);
		
		Id = new JTextField();
		loginPanel.add(Id);
		Id.setColumns(10);
		
		JLabel txtBlank1 = new JLabel("    ");
		loginPanel.add(txtBlank1);
		
		JLabel txtPwd = new JLabel("비밀번호");
		loginPanel.add(txtPwd);
		
		pwd = new JPasswordField();
		loginPanel.add(pwd);
		pwd.setColumns(10);
		
		JLabel txtBlank2 = new JLabel("    ");
		loginPanel.add(txtBlank2);
		
		loginBtn = new JButton("로그인");
		loginPanel.add(loginBtn);
		
		JLabel txtBlank3 = new JLabel("    ");
		loginPanel.add(txtBlank3);
		
		regBtn = new JButton("회원가입");
		loginPanel.add(regBtn);
		
		JPanel logoutPanel = new JPanel();
		FlowLayout flowLayout_1 = (FlowLayout) logoutPanel.getLayout();
		flowLayout_1.setVgap(20);
		flowLayout_1.setHgap(20);
		flowLayout_1.setAlignment(FlowLayout.LEFT);
		memberPanel.add(logoutPanel, "logoutPanel");
		
		txtInfo = new JLabel("000님 로그인 하셨습니다.");
		logoutPanel.add(txtInfo);
		
		logoutBtn = new JButton("로그아웃");
		logoutPanel.add(logoutBtn);
		
		JLabel txtSearch = new JLabel("검색");
		logoutPanel.add(txtSearch);
		
		searchBtn = new JTextField();
		logoutPanel.add(searchBtn);
		searchBtn.setColumns(10);
		
		
		
		

		/*
		 * 메인 부분의 표시 패널
		 */
		JPanel mainPanel = new JPanel();
		mainPanel.setPreferredSize(new Dimension(10, 550));
		contentPane.add(mainPanel, BorderLayout.SOUTH);
		mainPanel.setLayout(new CardLayout(0, 0));
		
		

		/*
		 * 탭 패널 설정
		 */
		JTabbedPane tabPanel = new JTabbedPane(JTabbedPane.TOP);
		mainPanel.add(tabPanel, "tabPanel");
		
		
		

		/*
		 * 유기견 관리 패널
		 */
		JPanel dogPanel = new JPanel();
		tabPanel.addTab("DOG", null, dogPanel, null);
		dogPanel.setLayout(new BorderLayout(0, 0));
		
		JScrollPane dogScroll = new JScrollPane();
		dogScroll.setPreferredSize(new Dimension(2, 200));
		dogPanel.add(dogScroll, BorderLayout.NORTH);
		
		dogTable = new JTable();
		dogTable.setPreferredScrollableViewportSize(new Dimension(32767, 32767));
		dogTable.setPreferredSize(new Dimension(2, 200));
		dogScroll.setViewportView(dogTable);
		
		JPanel dogDetail = new JPanel();
		dogDetail.setPreferredSize(new Dimension(490, 10));
		dogPanel.add(dogDetail, BorderLayout.WEST);
		
		JPanel dogMenu = new JPanel();
		dogMenu.setPreferredSize(new Dimension(500, 10));
		dogPanel.add(dogMenu, BorderLayout.EAST);
		
		

		/*
		 * 직원 관리 패널
		 */
		JPanel empPanel = new JPanel();
		tabPanel.addTab("EMPLOYEE", null, empPanel, null);
		empPanel.setLayout(new BorderLayout(0, 0));
		
		JScrollPane empScroll = new JScrollPane();
		empScroll.setPreferredSize(new Dimension(2, 200));
		empPanel.add(empScroll, BorderLayout.NORTH);
		
		empTable = new JTable();
		empTable.setPreferredSize(new Dimension(0, 200));
		empScroll.setViewportView(empTable);
		
		ed = new empDAO();
		Iterator<empVO> iter = ed.selectEmp().iterator();
		DefaultTableModel model = new DefaultTableModel();
		{
			
			model = new DefaultTableModel(){
				@Override
				public boolean isCellEditable(int row, int column) {
				return false;
				}
			};
			model.setColumnIdentifiers(
					new String[]{"사원번호","이름","보호소","부서","업무"});
							
			while(iter.hasNext()){
				empVO ev = iter.next();
				model.addRow(new String[]{ev.getEmpno(),ev.getSname(),ev.getDname(),ev.getEname(),
						ev.getJob()});
				}
		}
		
		empTable.setModel(model);
		
		empTable.getTableHeader().setReorderingAllowed(false);
		DefaultTableCellRenderer render = (DefaultTableCellRenderer)empTable.getDefaultRenderer(getClass());
		render.setHorizontalAlignment(SwingConstants.CENTER);
		
		empTable.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				if(e.getClickCount() == 2){
					int r = empTable.getSelectedRow();
					String empno = empTable.getValueAt(r, 0).toString();
				    ed = new empDAO();
				    ev = ed.selectDetailEmp(empno);
					txtEmpno.setText(ev.getEmpno());
					ename.setText(ev.getEname());
					sname.setText(ev.getSname());
					dname.setText(ev.getDname());
					addr.setText(ev.getAddr());
					job.setText(ev.getJob());
					sal.setText(ev.getSal());
					mgr.setText(ev.getMgr());
					hiredate.setText(ev.getHiredate());
					month.setText(ev.getSsn().split(" ")[0].substring(2,4));
					day.setText(ev.getSsn().split(" ")[0].substring(4,6));
					ssn1.setText(ev.getSsn().split(" ")[0].substring(0,6));
					ssn2.setText(ev.getSsn().split(" ")[0].substring(7,14));
					phone1.setText(ev.getPhone().split(" ")[0].substring(0,3));
					phone2.setText(ev.getPhone().split(" ")[0].substring(4,8));
					phone3.setText(ev.getPhone().split(" ")[0].substring(9,13));
					
				}
			}
		});
		
		JPanel empDetail = new JPanel();
		empDetail.setPreferredSize(new Dimension(750, 10));
		empPanel.add(empDetail, BorderLayout.CENTER);
		
		JLabel lblNewLabel = new JLabel("New label");
		lblNewLabel.setBorder(new LineBorder(new Color(0, 0, 0)));
		
		JLabel label = new JLabel("사원번호");
		
		txtEmpno = new JTextField();
		txtEmpno.setEditable(false);
		txtEmpno.setColumns(10);
		
		JLabel lblNewLabel_1 = new JLabel("이름");
		
		ename = new JTextField();
		ename.setEditable(false);
		ename.setColumns(10);
		
		JLabel lblNewLabel_2 = new JLabel("주민등록번호");
		
		ssn1 = new JTextField();
		ssn1.setEditable(false);
		ssn1.setColumns(10);
		
		JLabel lblNewLabel_3 = new JLabel("-");
		
		ssn2 = new JTextField();
		ssn2.setEditable(false);
		ssn2.setColumns(10);
		
		JLabel lblNewLabel_4 = new JLabel("주소");
		
		addr = new JTextField();
		addr.setColumns(10);
		
		JLabel lblNewLabel_5 = new JLabel("전화번호");
		
		phone1 = new JTextField();
		phone1.setColumns(10);
		
		JLabel lblNewLabel_6 = new JLabel("-");
		
		phone2 = new JTextField();
		phone2.setColumns(10);
		
		JLabel lblNewLabel_7 = new JLabel("-");
		
		phone3 = new JTextField();
		phone3.setColumns(10);
		
		JLabel lblNewLabel_8 = new JLabel("소속보호소");
		
		sname = new JTextField();
		sname.setColumns(10);
		
		JLabel label_1 = new JLabel("소속부서");
		
		dname = new JTextField();
		dname.setColumns(10);
		
		JLabel lblNewLabel_9 = new JLabel("업무");
		
		job = new JTextField();
		job.setColumns(10);
		
		JLabel lblNewLabel_10 = new JLabel("급여");
		
		sal = new JTextField();
		sal.setColumns(10);
		
		JLabel lblNewLabel_11 = new JLabel("만원");
		
		JLabel lblNewLabel_12 = new JLabel("입사일");
		
		hiredate = new JTextField();
		hiredate.setEditable(false);
		hiredate.setColumns(10);
		
		JLabel lblNewLabel_13 = new JLabel("상사");
		
		mgr = new JTextField();
		mgr.setColumns(10);
		
		JLabel lblNewLabel_14 = new JLabel("생일");
		
		month = new JTextField();
		month.setEditable(false);
		month.setColumns(10);
		
		JLabel lblNewLabel_15 = new JLabel("월");
		
		day = new JTextField();
		day.setEditable(false);
		day.setColumns(10);
		
		JLabel lblNewLabel_16 = new JLabel("일");
		
		final JComboBox comboSname = new JComboBox();
		comboSname.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				sname.setText((String) comboSname.getSelectedItem());
			}
		});
		comboSname.setModel(new DefaultComboBoxModel(new String[] {"한국동물구조관리협회", "카라(사)동물보호시민단체", "동물학대방지연합", "부산동물학대방지연합", "대전동물보호센터", "동물보호센터", "한국동물보호협회", "동물자유연대", "부산유기동물보호협회", "하늘아이", "동물사랑실천협회", "캐비클럽", "동물보호관리시스템", "(사)한국야생동물보호협회"}));
		
		final JComboBox comboJob = new JComboBox();
		comboJob.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				dname.setText((String)comboJob.getSelectedItem());
			}
		});
		comboJob.setModel(new DefaultComboBoxModel(new String[] {"동물구조", "시설관리", "자재관리", "동물관리", "사무"}));
		GroupLayout gl_empDetail = new GroupLayout(empDetail);
		gl_empDetail.setHorizontalGroup(
			gl_empDetail.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_empDetail.createSequentialGroup()
					.addGap(4)
					.addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 205, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(gl_empDetail.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_empDetail.createSequentialGroup()
							.addComponent(lblNewLabel_8)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(sname, GroupLayout.PREFERRED_SIZE, 240, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(comboSname, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_empDetail.createSequentialGroup()
							.addComponent(lblNewLabel_4)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(addr, GroupLayout.PREFERRED_SIZE, 483, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_empDetail.createSequentialGroup()
							.addGroup(gl_empDetail.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_empDetail.createSequentialGroup()
									.addComponent(lblNewLabel_10)
									.addPreferredGap(ComponentPlacement.RELATED)
									.addComponent(sal, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
									.addPreferredGap(ComponentPlacement.RELATED)
									.addComponent(lblNewLabel_11))
								.addGroup(gl_empDetail.createSequentialGroup()
									.addGroup(gl_empDetail.createParallelGroup(Alignment.TRAILING)
										.addComponent(label)
										.addComponent(lblNewLabel_5))
									.addPreferredGap(ComponentPlacement.RELATED)
									.addGroup(gl_empDetail.createParallelGroup(Alignment.LEADING)
										.addGroup(gl_empDetail.createSequentialGroup()
											.addComponent(txtEmpno, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(lblNewLabel_1)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(ename, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(lblNewLabel_14)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(month, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(lblNewLabel_15)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(day, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(lblNewLabel_16))
										.addGroup(gl_empDetail.createSequentialGroup()
											.addComponent(phone1, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(lblNewLabel_6)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(phone2, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(lblNewLabel_7)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(phone3, GroupLayout.PREFERRED_SIZE, 73, GroupLayout.PREFERRED_SIZE)))
									.addGap(27))
								.addGroup(Alignment.TRAILING, gl_empDetail.createSequentialGroup()
									.addGroup(gl_empDetail.createParallelGroup(Alignment.LEADING)
										.addGroup(gl_empDetail.createSequentialGroup()
											.addComponent(lblNewLabel_9)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(job, 0, 0, Short.MAX_VALUE)
											.addGap(17)
											.addComponent(lblNewLabel_12))
										.addGroup(gl_empDetail.createSequentialGroup()
											.addComponent(label_1)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(dname, GroupLayout.PREFERRED_SIZE, 91, GroupLayout.PREFERRED_SIZE)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(comboJob, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
									.addPreferredGap(ComponentPlacement.RELATED)
									.addGroup(gl_empDetail.createParallelGroup(Alignment.LEADING)
										.addGroup(gl_empDetail.createSequentialGroup()
											.addComponent(lblNewLabel_13)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(mgr, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
										.addComponent(hiredate, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
							.addGap(137))
						.addGroup(gl_empDetail.createSequentialGroup()
							.addComponent(lblNewLabel_2)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(ssn1, GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(lblNewLabel_3)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(ssn2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
					.addContainerGap())
		);
		gl_empDetail.setVerticalGroup(
			gl_empDetail.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_empDetail.createSequentialGroup()
					.addGroup(gl_empDetail.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_empDetail.createSequentialGroup()
							.addContainerGap()
							.addGroup(gl_empDetail.createParallelGroup(Alignment.BASELINE)
								.addComponent(label)
								.addComponent(txtEmpno, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblNewLabel_1)
								.addComponent(ename, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblNewLabel_14)
								.addComponent(month, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblNewLabel_15)
								.addComponent(day, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblNewLabel_16))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_empDetail.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_2)
								.addComponent(ssn1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblNewLabel_3)
								.addComponent(ssn2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_empDetail.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_4)
								.addComponent(addr, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_empDetail.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_5)
								.addComponent(phone1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblNewLabel_6)
								.addComponent(phone2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblNewLabel_7)
								.addComponent(phone3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_empDetail.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_8)
								.addComponent(sname, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(comboSname, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_empDetail.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_13)
								.addComponent(mgr, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addGap(2)
							.addGroup(gl_empDetail.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_9)
								.addComponent(lblNewLabel_12)
								.addComponent(hiredate, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(job, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_empDetail.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_10)
								.addComponent(sal, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblNewLabel_11)))
						.addGroup(gl_empDetail.createSequentialGroup()
							.addGap(5)
							.addGroup(gl_empDetail.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel, GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
								.addComponent(label_1)
								.addComponent(dname, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(comboJob, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
					.addContainerGap())
		);
		empDetail.setLayout(gl_empDetail);
		
		JPanel empMenu = new JPanel();
		empMenu.setBorder(new LineBorder(new Color(0, 0, 0)));
		empMenu.setPreferredSize(new Dimension(240, 10));
		empPanel.add(empMenu, BorderLayout.EAST);
		
		final JComboBox comboTitle = new JComboBox();
		comboTitle.setModel(new DefaultComboBoxModel(new String[] {"사원번호", "이름", "보호소", "부서","업무"}));
		
		txtFind = new JTextField();
		txtFind.setColumns(10);
		
		final JButton findBtn = new JButton("검색");
		findBtn.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(txtFind.getText().isEmpty()){
					JOptionPane.showMessageDialog(null, "검색할 단어를 작성해주세요!");
					return;
				}
				int title = comboTitle.getSelectedIndex()+1;
				String keyword = txtFind.getText();
								
				empTable.removeAll();
				ed = new empDAO();
				Iterator<empVO> iter = ed.selectFindEmp(title, keyword).iterator();
				DefaultTableModel model = new DefaultTableModel();
				{
					
					model = new DefaultTableModel(){
						@Override
						public boolean isCellEditable(int row, int column) {
						return false;
						}
					};
					model.setColumnIdentifiers(
							new String[]{"사원번호","이름","보호소","부서","업무"});
				while(iter.hasNext()){
					ev = iter.next();
					model.addRow(new String[]{ev.getEmpno(),ev.getSname(),ev.getDname(),ev.getEname(),
							ev.getJob()});
					}
				
				empTable.setModel(model);
				DefaultTableCellRenderer render = (DefaultTableCellRenderer)empTable.getDefaultRenderer(getClass());
				render.setHorizontalAlignment(SwingConstants.CENTER);
				
			}
			}
		});
		
		final JButton updateBtn = new JButton("수정");
		updateBtn.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				int choice = JOptionPane.showConfirmDialog(updateBtn,"수정하시겠습니까?","직원정보수정",JOptionPane.YES_NO_OPTION);
				if(choice == JOptionPane.YES_OPTION){
					ev = new empVO();
					
					ev.setSname(ed.selectSnameEmp(sname.getText()));
					ev.setDname(ed.selectDnameEmp(dname.getText()));
					ev.setMgr(ed.selectMgrEmp(mgr.getText()));
					ev.setJob(job.getText());
					ev.setSal(sal.getText());
					ev.setEmpno(txtEmpno.getText());
					ev.setPhone(phone1.getText()+"-"+phone2.getText()+"-"+phone3.getText());
					
					if(ed.updateEmp(ev)>0){
										
					Iterator<empVO> iter = ed.selectEmp().iterator();
					DefaultTableModel model = new DefaultTableModel();
					{
						model = new DefaultTableModel(){
							@Override
							public boolean isCellEditable(int row, int column) {
							return false;
							}
						};
						model.setColumnIdentifiers(
								new String[]{"사원번호","이름","보호소","부서","업무"});
										
						while(iter.hasNext()){
							empVO ev = iter.next();
							model.addRow(new String[]{ev.getEmpno(),ev.getSname(),ev.getDname(),ev.getEname(),
									ev.getJob()});
							}
					}
					
					empTable.setModel(model);
					// empTable.repaint();
					empTable.getTableHeader().setReorderingAllowed(false);
					DefaultTableCellRenderer render = (DefaultTableCellRenderer)empTable.getDefaultRenderer(getClass());
					render.setHorizontalAlignment(SwingConstants.CENTER);
					JOptionPane.showMessageDialog(null, "수정완료!");
					}
					else dispose();
					
				}
				
			}
		});
		
		JButton allBtn = new JButton("전체조회");
		allBtn.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ed = new empDAO();
				Iterator<empVO> iter = ed.selectEmp().iterator();
				DefaultTableModel model = new DefaultTableModel();
				{
					
					model = new DefaultTableModel(){
						@Override
						public boolean isCellEditable(int row, int column) {
						return false;
						}
					};
					model.setColumnIdentifiers(
							new String[]{"사원번호","이름","보호소","부서","업무"});
									
					while(iter.hasNext()){
						empVO ev = iter.next();
						model.addRow(new String[]{ev.getEmpno(),ev.getSname(),ev.getDname(),ev.getEname(),
								ev.getJob()});
						}
				}
				
				empTable.setModel(model);
				
				empTable.getTableHeader().setReorderingAllowed(false);
				DefaultTableCellRenderer render = (DefaultTableCellRenderer)empTable.getDefaultRenderer(getClass());
				render.setHorizontalAlignment(SwingConstants.CENTER);
			}
		});
		GroupLayout gl_empMenu = new GroupLayout(empMenu);
		gl_empMenu.setHorizontalGroup(
			gl_empMenu.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_empMenu.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_empMenu.createParallelGroup(Alignment.LEADING)
						.addComponent(updateBtn)
						.addGroup(gl_empMenu.createSequentialGroup()
							.addGroup(gl_empMenu.createParallelGroup(Alignment.LEADING)
								.addComponent(comboTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(findBtn))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_empMenu.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_empMenu.createSequentialGroup()
									.addGap(10)
									.addComponent(allBtn))
								.addComponent(txtFind, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
					.addContainerGap(29, Short.MAX_VALUE))
		);
		gl_empMenu.setVerticalGroup(
			gl_empMenu.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_empMenu.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_empMenu.createParallelGroup(Alignment.BASELINE)
						.addComponent(comboTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(txtFind, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(gl_empMenu.createParallelGroup(Alignment.BASELINE)
						.addComponent(findBtn)
						.addComponent(allBtn))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(updateBtn)
					.addContainerGap(230, Short.MAX_VALUE))
		);
		empMenu.setLayout(gl_empMenu);

		
		
		/*
		 * 입양자 관리 패널
		 */
		JPanel adoPanel = new JPanel();
		tabPanel.addTab("ADOPTER", null, adoPanel, null);
		adoPanel.setLayout(new BorderLayout(0, 0));
		
		JScrollPane adoScroll = new JScrollPane();
		adoScroll.setPreferredSize(new Dimension(2, 200));
		adoPanel.add(adoScroll, BorderLayout.NORTH);
		
		adoTable = new JTable();
		adoTable.setPreferredSize(new Dimension(0, 200));
		adoScroll.setViewportView(adoTable);
		
		JPanel adoDetail = new JPanel();
		adoDetail.setPreferredSize(new Dimension(490, 10));
		adoPanel.add(adoDetail, BorderLayout.WEST);
		
		JPanel adoMenu = new JPanel();
		adoMenu.setPreferredSize(new Dimension(500, 10));
		adoPanel.add(adoMenu, BorderLayout.EAST);

		
		
		/*
		 * 게시판 탭 패널
		 * 추후 구현 예정
		 */
		JPanel boardPanel = new JPanel();
		tabPanel.addTab("BOARD", null, boardPanel, null);
		
		
		
		
		/*
		 * 프로그램 최초 실행시 표시되는 패널
		 */
		JPanel indexPanel = new JPanel();
		mainPanel.add(indexPanel, "indexPanel");
		indexPanel.setLayout(new BorderLayout(0, 0));
		
		JPanel indexDog = new JPanel();
		indexPanel.add(indexDog, BorderLayout.WEST);
		
		JPanel indexBbs = new JPanel();
		indexPanel.add(indexBbs, BorderLayout.EAST);
		
		
		
		
		/*
		 * 회원 정보 표시 패널 
		 */
		JPanel myPanel = new JPanel();
		mainPanel.add(myPanel, "myPanel");
		
		
		
		
		/*
		 * 관리자 페이지 패널
		 */
		JPanel adminPanel = new JPanel();
		mainPanel.add(adminPanel, "adminPanel");
	}
}
